const download = require('npm-gitee-lw');
const ora = require("ora");
const path = require("path");

module.exports = function(url, target) {
  target = path.join(target || ".", ".download-temp");
  return new Promise((res, rej) => {
    const spinner = ora(`模板下载中...`);
    spinner.start();
    download(url, target, err => {
      if (err) {
        spinner.fail();
        rej(err);
      } else {
        spinner.succeed();        
        res(target);//返回下载的模板存放的临时路径（.download-temp)
      }
    });
  });
};
